﻿using System.Collections.Generic;
using winS.UnityEditor.Undo;

namespace winS.UnityEditor.ProcessEditor
{
    public class MoveNodeCommand : IUndoCommand
    {
        public string info => "移动节点";

        private readonly IEnumerable<ElementMoveInfo> elementMoveInfos;

        public MoveNodeCommand(IEnumerable<ElementMoveInfo> elementMoveInfos)
        {
            this.elementMoveInfos = elementMoveInfos;
        }

        public void Redo()
        {
            foreach (var elementMoveInfo in elementMoveInfos) elementMoveInfo.graphElement.position = elementMoveInfo.newPosition;
        }
        public void Undo()
        {
            foreach (var elementMoveInfo in elementMoveInfos) elementMoveInfo.graphElement.position = elementMoveInfo.oldPosition;
        }
    }
}